#include "calc.h"



void calc::doit() {
	try {
		if (sourceStr.empty()) {
			throw (sfError(BLANK_STR, "blank string"));
		}
		check();
		startCalc();
	} catch (...) {
		throw;
	}
}


bool calc::judgeCmd() {
	try {
		//add code to run cmd
		if (sourceStr == "clhst") {
			outLog("clear the history");
			convstr = "clear the history";
			history.clear();
			return true;
		} else if (sourceStr == "cllog") {
			eventLog.clear();
			convstr = "clear the event log";
			return true;
		} else if (sourceStr == "clall") {
			history.clear();
			eventLog.clear();
			convstr = "clear all";
			return true;
		} else if (sourceStr == "hst") {
			outLog("show history!");
			convstr = history;
			return true;
		} else if (sourceStr == "log") {
			outLog("show event log!");
			convstr = eventLog;
			return true;
		}
		return false;
	} catch (...) {
		throw;
	}
}
